We want to use it there too, in the future.
Update all callers.
const char *theme,
int size);
gboolean gdk_running_in_sandbox (void);
+gboolean gdk_should_use_portal (void);
const gchar * gdk_get_startup_notification_id (void);
return g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS);
}
+gboolean
+gdk_should_use_portal (void)
+{
+ static const char *use_portal = NULL;
+
+ if (G_UNLIKELY (use_portal == NULL))
+ {
+ if (gdk_running_in_sandbox ())
+ use_portal = "1";
+ else
+ {
+ use_portal = g_getenv ("GTK_USE_PORTAL");
+ if (!use_portal)
+ use_portal = "";
+ }
+ }
+
+ return use_portal[0] == '1';
+}
+
/**
* SECTION:threads
* @Short_description: Functions for using GDK in multi-threaded programs
dbus->object_path = g_application_get_dbus_object_path (G_APPLICATION (impl->application));
dbus->unique_name = g_dbus_connection_get_unique_name (dbus->session);
- if (gtk_should_use_portal ())
+ if (gdk_should_use_portal ())
goto out;
g_debug ("Connecting to session manager");
GVariant *ret;
guint version;
- if (!gtk_should_use_portal ())
+ if (!gdk_should_use_portal ())
return FALSE;
picker->portal_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
GtkFileChooserAction action;
const char *method_name;
- if (!gtk_should_use_portal ())
+ if (!gdk_should_use_portal ())
return FALSE;
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
GtkWindow *parent,
gboolean *do_print)
{
- if (gtk_should_use_portal ())
+ if (gdk_should_use_portal ())
return gtk_print_operation_portal_run_dialog (op, show_dialog, parent, do_print);
else
return gtk_print_operation_unix_run_dialog (op, show_dialog, parent, do_print);
GtkWindow *parent,
GtkPrintOperationPrintFunc print_cb)
{
- if (gtk_should_use_portal ())
+ if (gdk_should_use_portal ())
gtk_print_operation_portal_run_dialog_async (op, show_dialog, parent, print_cb);
else
gtk_print_operation_unix_run_dialog_async (op, show_dialog, parent, print_cb);
GtkWindow *parent,
const gchar *filename)
{
- if (gtk_should_use_portal ())
+ if (gdk_should_use_portal ())
gtk_print_operation_portal_launch_preview (op, surface, parent, filename);
else
gtk_print_operation_unix_launch_preview (op, surface, parent, filename);
g_once (®ister_resources_once, register_resources, NULL);
}
-gboolean
-gtk_should_use_portal (void)
-{
- static const char *use_portal = NULL;
-
- if (G_UNLIKELY (use_portal == NULL))
- {
- char *path;
-
- path = g_build_filename (g_get_user_runtime_dir (), "flatpak-info", NULL);
- if (g_file_test (path, G_FILE_TEST_EXISTS))
- use_portal = "1";
- else
- {
- use_portal = g_getenv ("GTK_USE_PORTAL");
- if (!use_portal)
- use_portal = "";
- }
- g_free (path);
- }
-
- return use_portal[0] == '1';
-}
-
static char *
get_portal_path (GDBusConnection *connection,
const char *kind,
#include <glib-object.h>
#include <gdk/gdk.h>
+#include <gdk/gdk-private.h>
#include "gtkcsstypesprivate.h"
#include "gtktexthandleprivate.h"
gdouble _gtk_get_slowdown (void);
void _gtk_set_slowdown (gdouble slowdown_factor);
-gboolean gtk_should_use_portal (void);
char *gtk_get_portal_request_path (GDBusConnection *connection,
char **token);
char *gtk_get_portal_session_path (GDBusConnection *connection,